﻿@inject IHttpService _httpService
@inject NavigationManager NavigationManager
@inject IDataCacheService _dataCacheService

@foreach (var item in _dataCacheService.RandomTagsCatche.Take(1))
{
    <CnGalWebSite.Components.Containers.MasaTitleContainer Outline Title="@item.Name" Icon="@IconType.Tag.ToIconString()" ShowMoreButton OnClickMore="@(()=>OnClickMore("/tags/index/"+item.Id))">
            <MSlideGroup ShowArrows="true" Class="slide-group-garp">
                <ChildContent>
                    @foreach (var temp in item.Entries)
                    {
                        <MSlideItem>
                                <RandomTagViewTip Model="temp"/>
                        </MSlideItem>
                    }
                </ChildContent>

            </MSlideGroup>
    </CnGalWebSite.Components.Containers.MasaTitleContainer>
}


@code {
    [CascadingParameter]
    public ErrorHandler ErrorHandler { get; set; }

    protected override async Task OnInitializedAsync()
    {

        try
        {
            if (_dataCacheService.RandomTagsCatche.Count == 0)
            {
                _dataCacheService.RandomTagsCatche = await _httpService.GetAsync<List<RandomTagModel>>("api/tags/GetRandomTags");
            }

            _dataCacheService.RandomTagsCatche.Random();
        }
        catch (Exception ex)
        {
            await ErrorHandler.ProcessError(ex, "获取广场随机标签列表失败");
        }
    }
    public void OnClickMore(string url)
    {
        NavigationManager.NavigateTo(url);
        
    }

}
